package com.af.system.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : zhenyun.su
 * @since : 2023/3/21
 */


public class DemoTreeVo extends AfTreeNode<DemoTreeVo> {
    private String name;

    public static DemoTreeVo of(Long id, Long parentId, String name){
        DemoTreeVo treeVo = new DemoTreeVo();
        treeVo.setId(id);
        treeVo.setPid(parentId);
        treeVo.setName(name);
        return treeVo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void main(String[] args) {
        List<DemoTreeVo> sources = new ArrayList<>();
        sources.add(DemoTreeVo.of(1L, 0L, "A"));
        sources.add(DemoTreeVo.of(2L, 0L, "B"));
        sources.add(DemoTreeVo.of(11L, 1L, "A1"));
        sources.add(DemoTreeVo.of(12L, 1L, "A2"));
        sources.add(DemoTreeVo.of(13L, 1L, "A3"));
        sources.add(DemoTreeVo.of(21L, 2L, "B1"));
        List<DemoTreeVo> newTree = AfTreeUtils.buildTree(sources, 0L);
        System.out.println(newTree);
        String leadIds = AfTreeUtils.leafNodeIds.toString();
        System.out.println(leadIds);
    }

    @Override
    public String toString() {
        return "DemoTreeVo{" +
                "id=" + id +
                ", pid=" + pid +
                ", leafed=" + leafed +
                ", children=" + children +
                ", name='" + name + '\'' +
                '}';
    }
}
